﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class adminstrator_planCourse : System.Web.UI.Page
{
    string mysql;
    CommDB mydb = new CommDB();
    DataSet myds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string cName = Request.QueryString["cName"];
            Label1.Text="(" + cName + ")";
            bind();
        }
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        string tNo = GridView1.DataKeys[e.NewPageIndex][0].ToString();
        string tName = GridView1.DataKeys[e.NewPageIndex][1].ToString();
        string cNo = Request.QueryString["cNo"];
        mysql = "UPDATE course SET tNo='" + tNo + "',tName =' " +
            tName + "' WHERE cNo='" + cNo + "'";
        mydb.ExecuteNonQuery(mysql);
        Response.Redirect("plancourse.aspx");
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.PageIndex = e.NewEditIndex;
        bind();
    }
    public void bind()
    {
        mysql = "SELECT * FROM teacher";
        myds = mydb.ExecuteQuery(mysql, "teacher");
        GridView1.DataSource = myds.Tables["teacher"];
        GridView1.DataKeyNames = new string[] { "tNo", "tName" };
        GridView1.DataBind();
    }


}